package controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class AddController implements Controller {
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView("index");
		mav.addObject("title", "I am a calculator~");
		String a = "0", b = "0";
		if (request.getParameter("a") != null)
			a = request.getParameter("a");
		if (request.getParameter("b") != null)
			b = request.getParameter("b");
		int ia = Integer.valueOf(a);
		int ib = Integer.valueOf(b);
		mav.addObject("result", Integer.toString(ia + ib));
		return mav;
	}
}